package com.fa.controller;

import com.fa.entity.Tenant;
import com.fa.service.impl.TenantService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/tenants")
public class TenantController {
    private final TenantService tenantService;

    public TenantController(TenantService tenantService) {
        this.tenantService = tenantService;
    }

    @PostMapping
    public void addTenant(@RequestBody Tenant tenant) {
        tenantService.addTenant(tenant);
    }

    @DeleteMapping("/{id}")
    public void removeTenant(@PathVariable Long id) {
        tenantService.removeTenant(id);
    }

    @GetMapping
    public List<Tenant> listTenants() {
        return tenantService.list();
    }
}
